﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Dynamic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Webdiyer.WebControls.Mvc;
using Zor_Bll;
using Zor_Modes;
using Zor_Tools;
using Zor_Web.Models;
using Zor_Web.Models.Base;
using System.Text;

namespace Zor_Web.Controllers
{
    [Authorization]
    public class BaseController : Controller
    {
      
        #region - 销号管理 -

        /// <summary>
        /// 销号信息列表加载数据
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>

        public ActionResult Disannul_Operation(V_Disannul Model, int? index = 1, string where = null)
        {

            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_Zor_Summary_Operation> smPager = Zor_Disannul_Bll<V_Zor_Summary_Operation>.MGetPageList(pageIndex, out totalCount, "   Dn_Id=" + where + "  and Sm_State=1 ").AsQueryable().ToPagedList(0, 10) as PagedList<V_Zor_Summary_Operation>;
            //smPager.TotalItemCount = totalCount;
            //smPager.CurrentPageIndex = (int)(index ?? 1);
            //V_Zor_Summary_Operation vb = new V_Zor_Summary_Operation();
            //vb.PageData = smPager;
            //return View(vb);
            return Content(smPager.ToJson());
        }
        /// <summary>
        /// 销号加载数据
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        public ActionResult Disannul(V_Disannul Model, int? index = 1, string where = null)
        {
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_Disannul> smPager = Zor_Disannul_Bll<V_Disannul>.GetDisannulPageList(Model, pageIndex, out totalCount, "Dn_State=1 and Dn_UserId in(   select User_Id from Sys_Users where    DT_Id in (select Dt_Id  from  Sys_Department where   Dt_ParentId in(select DT_Id from Sys_Users where   User_Id=  " + RequestSession.GetSessionUser().User_Id + ")))").AsQueryable().ToPagedList(0, 10) as PagedList<V_Disannul>;
            //PagedList<V_Disannul> smPager = Zor_Summary_Bll<V_Disannul>.GetPageList(Model, pageIndex, out totalCount, where).AsQueryable().ToPagedList(0, 10) as PagedList<V_Disannul>;
            smPager.TotalItemCount = totalCount;
            smPager.CurrentPageIndex = (int)(index ?? 1);
            V_Disannul vb = new V_Disannul();
            vb.PageData = smPager;
            return View(vb);
        }
        /// <summary>
        /// 消号
        /// </summary>
        /// <param name="accpid">受理单ｉｄ</param>      
        /// <param name="actualtax">税金总和</param>
        /// <param name="dndate">消号时间</param>     
        /// <param name="Jksbh">缴款书编号</param>   
        /// <param name="Sm_Id">汇总主键ｉｄ </param>
        /// 受理状态(0保存,1提交2被退回、3已评议4已评定5、已审核、6已缴税、7、已开票8、已消号、9已汇总)
        /// <returns></returns>
        public ActionResult SummaryDisannul(int Dn_Id, string[] accpid, double Grsds, double Fcs,double actualtax, int dndate, string Jksbh, string [] Bd_Id)
        {
            BaseAnswer bar = new BaseAnswer();
            bar = Zor_Disannul_Bll<dynamic>.SummaryDisannul(Dn_Id, accpid, Grsds, Fcs, actualtax, dndate, Jksbh, Bd_Id);
            return Content(bar.ToJson());
        }
        #endregion

        #region - 汇总管理 -
        /// <summary>
        /// 汇总管理列表
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="TotalCount">返回值</param>
        /// <returns></returns>
        public ActionResult Zor_Summary(V_Disannul model, int? index = 1, string where = null)
        {
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_Disannul> smPager = Zor_Summary_Bll<V_Disannul>.GetPageList(model, pageIndex, out totalCount, " Dn_UserId= " + RequestSession.GetSessionUser().User_Id + " ").AsQueryable().ToPagedList(0, 10) as PagedList<V_Disannul>;

            smPager.TotalItemCount = totalCount;
            smPager.CurrentPageIndex = (int)(index ?? 1);
            V_Disannul vb = new V_Disannul();
            vb.PageData = smPager;
            return View(vb);
        }
        /// <summary>
        /// 获取未汇总管理列表
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="TotalCount">返回值</param>
        /// <returns></returns>
        public ActionResult Zor_Summary_Operation(int? index = 1, string where = null)
        {
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_Zor_Summary_Operation> smPager = Zor_Summary_Bll<V_Zor_Summary_Operation>.MGetPageList(pageIndex, out totalCount, " Sm_State=0   and  Dt_Id  in (select Dt_Id  from dbo.Sys_Department where Dt_ParentId=" + RequestSession.GetSessionUser().DT_Id + ") and EReviewRent <=3150000 ").AsQueryable().ToPagedList(0, 10) as PagedList<V_Zor_Summary_Operation>;
            smPager.TotalItemCount = totalCount;
            smPager.CurrentPageIndex = (int)(index ?? 1);
            V_Zor_Summary_Operation vb = new V_Zor_Summary_Operation();
            vb.PageData = smPager;
            return View(vb);
        }
        /// <summary>
        /// 汇总
        /// </summary> 
        /// <param name="str">传进来数组形式：受理单ｉｄ，汇总主键ｉｄ，汇总金额</param>             
        /// <returns></returns>
        public ActionResult UpdateSummary(string[] strb)
        {
            BaseAnswer bar = new BaseAnswer();
            bar = Zor_Summary_Bll<dynamic>.UpdateSummary(strb);
            return Content(bar.ToJson());
        }
        /// <summary>
        /// 取消汇总
        /// </summary>
        /// <param name="accpid">受理单ｉｄ</param>      
        /// <param name="Dn_Id">消号表id</param>
        /// 受理状态(0保存,1提交2被退回、3已评议4已评定5、已审核、6已缴税、7、已开票8、已消号、9已汇总)
        /// <returns></returns>
        public ActionResult CancelSummary(int Dn_Id, string accpid)
        {
            BaseAnswer bar = new BaseAnswer();
            bar = Zor_Summary_Bll<dynamic>.CancelSummary(Dn_Id, accpid);
            return Content(bar.ToJson());
        }    
        /// <summary>
        /// 打印列表
        /// </summary>
        /// <returns></returns>
        public ActionResult Print_Summary(int where)
        {
            List<V_Print_Summary> listDtName = Zor_Summary_Bll<V_Print_Summary>.Print_Summary(where);
            return Content(listDtName.ToJson());
        }

        /// <summary>
        /// 打印份数
        /// </summary>
        /// <returns></returns>
 
        public ActionResult Copies(int Id)
        {
            List<dynamic> listDtName = Zor_Summary_Bll<dynamic>.GetCopies(Id);
            return Content(listDtName.ToJson());
        }
        /// <summary>
        /// 打印总金额
        /// </summary>
        /// <returns></returns>
       
        public ActionResult SumMoney(int Id)
        {
            List<dynamic> listDtName = Zor_Summary_Bll<dynamic>.GetSumMoney(Id);
            return Content(listDtName.ToJson());
        }
        
        /// <summary>
        /// 汇总时间
        /// </summary>
        /// <returns></returns>

        public ActionResult Sm_Date(int Id)
        {
            List<dynamic> listDtName = Zor_Summary_Bll<dynamic>.GetSm_Date(Id);
            return Content(listDtName.ToJson());
        }
       

        #endregion

        #region - 发票号管理 -
        public ActionResult Zor_Invoice(V_Zor_Invoice model, int? index = 1, string where = null)
        {
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_Zor_Invoice> zvPager = Zor_Invoice_Bll<V_Zor_Invoice>.GetPageList(model, pageIndex, out totalCount, where).AsQueryable().ToPagedList(0, 10) as PagedList<V_Zor_Invoice>;
            zvPager.TotalItemCount = totalCount;
            zvPager.CurrentPageIndex = (int)(index ?? 1);
            V_Zor_Invoice vb = new V_Zor_Invoice();
            vb.PageData = zvPager;
            return View(vb);
        }
        /// <summary>
        /// 录入发票号
        /// </summary>
        /// <param name="accpid">受理单ｉｄ</param>      
        /// <param name="In_Id">发票号主键ｉｄ</param>
        /// <param name="pt_Id">税收ｉｄ</param>
        /// <param name="Grsds">个人所得税</param>
        /// <param name="Fcs">房产税</param>
        /// <param name="acttualtax">税金</param>
        /// <returns></returns>      
        public ActionResult UpdateInvoice(double Grsds, double Fcs, int In_Id, int accpid, int pt_Id, string InNumBer, double acttualtax)
        {
            BaseAnswer bar = new BaseAnswer();
            bar = Zor_Invoice_Bll<dynamic>.UpdateInvoice(Grsds, Fcs,In_Id, accpid, pt_Id, InNumBer, acttualtax);
            return Content(bar.ToJson());   
        }
        /// <summary>
        /// 修改录入发票号
        /// </summary>
        /// <param name="accpid">受理单ｉｄ</param>      
        /// <param name="In_Id">发票号主键ｉｄ</param>
        /// <param name="pt_Id">税收ｉｄ</param>
        /// <returns></returns>      
        public ActionResult UpdateInvoiceNum(int In_Id,  string InNumBer)
        {
            BaseAnswer bar = new BaseAnswer();
            bar = Zor_Invoice_Bll<dynamic>.UpdateInvoiceNum(In_Id,InNumBer);
            return Content(bar.ToJson());
        }
        #endregion

        #region - 缴税管理 -
        /// <summary>
        ///缴税列表
        /// </summary>
        /// <param name="model">实体类</param>
        /// <param name="index">页数</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        public ActionResult Zor_PayTaxes(V_Zor_PayTaxes model, int? index = 1, string where = null)
        {
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_Zor_PayTaxes> zvPager = Zor_PayTaxes_Bll<V_Zor_PayTaxes>.GetPageList(model, pageIndex, out totalCount, where).AsQueryable().ToPagedList(0, 10) as PagedList<V_Zor_PayTaxes>;
            zvPager.TotalItemCount = totalCount;
            zvPager.CurrentPageIndex = (int)(index ?? 1);
            V_Zor_PayTaxes vb = new V_Zor_PayTaxes();
            vb.PageData = zvPager;
            return View(vb);
        }
        /// <summary>
        /// 缴税管理－缴税
        /// </summary>
        /// create zhl by 17.4.10
        /// <param name="acceptance_Id">受理单ｉｄ</param>
        /// <param name="actualtax">实际缴费额</param>
        /// <param name="pt_Id">缴税主键ｉｄ</param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult AddPayTaxes(int acceptance_Id, double actualtax, int pt_Id)
        {

            string messge = Zor_PayTaxes_Bll<dynamic>.AddPayTaxes(acceptance_Id, actualtax,pt_Id);
            string msg = "{'AnswerMeg':'" + messge + "'}";
            return Content(msg.ToJson().ToString());

        }
        /// <summary>
        /// 获取所属部门上级部门
        /// </summary>
        /// <returns></returns>
        public ActionResult GetDtName_Up()
        {
            List<Sys_Department> listDtName = Zor_PayTaxes_Bll<Sys_Department>.GetDtName_Up();
            return Content(listDtName.ToJson());
        }

 
        #endregion

        #region - 审核管理 -
        /// <summary>
        /// 评定管理列表
        /// create zhl by 2017.3.29  
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        public ActionResult Zor_Examine(V_Zor_Examine Model, int? index = 1, string where = null)
        {
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_Zor_Examine> Examine = Zor_Examine_Bll<V_Zor_Examine>.GetPageList(Model,pageIndex, out totalCount, where).AsQueryable().ToPagedList(0, 10) as PagedList<V_Zor_Examine>;
            Examine.TotalItemCount = totalCount;
            Examine.CurrentPageIndex = (int)(index ?? 1);
            V_Zor_Examine vr = new V_Zor_Examine();
            vr.PageData = Examine;
            return View(vr);
        }

       /// <summary>
       /// 根据审核ID获取审核信息
       /// </summary>
       /// <param name="Examine_Id"></param>
       /// <returns></returns>
        public ActionResult getExamineInfo(int ExamineId)
        {

            List<V_Zor_Examine> lst_ExamineInfo = Zor_Examine_Bll<V_Zor_Examine>.getExamineInfo(ExamineId);
            return Content(lst_ExamineInfo.ToJson());
        }

        /// <summary>
        /// 审核
        /// create zhl by 17.3.31
        /// </summary>
        /// <param name="examine">审核对象</param>
        public ActionResult Examine(Zor_Examine examine, string accpid, double rentMoney)
        {
            BaseAnswer bar = new BaseAnswer();
            bar = Zor_Examine_Bll<dynamic>.Examine(examine, accpid, rentMoney);
            return Content(bar.ToJson());         

        }

        /// <summary>
        /// 退回至评定
        /// 评定状态(0正在评定,1已评定,2退回到评评定)
        /// </summary>
        /// <param name="aptid">受理单id</param>
        /// <returns></returns>
        public ActionResult ReturnEvaluate(Zor_Examine examine, string accpid)
        {
            BaseAnswer bar = new BaseAnswer();
            bar = Zor_Examine_Bll<dynamic>.ReturnEvaluate(examine, accpid);
            return Content(bar.ToJson());
        }
        #endregion

        #region - 评定管理 -
        /// <summary>
        /// 评定管理列表
        /// create zhl by 2017.3.29  
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        public ActionResult Zor_Evaluate(V_Zor_Evaluate Model, int? index = 1, string where = null)
        {
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_Zor_Evaluate> Evaluate = Zor_Evaluate_Bll<V_Zor_Evaluate>.GetPageList(Model,pageIndex, out totalCount, where).AsQueryable().ToPagedList(0, 10) as PagedList<V_Zor_Evaluate>;
            Evaluate.TotalItemCount = totalCount;
            Evaluate.CurrentPageIndex = (int)(index ?? 1);
            V_Zor_Evaluate vr = new V_Zor_Evaluate();
            vr.PageData = Evaluate;
            return View(vr);
        } 
        /// <summary>
        /// 推送提交至审核
        /// create zhl by 17.3.31
        /// </summary>
        /// <param name="evaluate">评定对象</param>
        /// <returns>2--当前评议已推送-1操作失败1--操作成功的标识</returns>
        public ActionResult Evaluate(Zor_Evaluate evaluate, string accpid)
        {
            string messge = Zor_Evaluate_Bll<dynamic>.Evaluate(evaluate, accpid);
            string msg = "{'AnswerMeg':'" + messge + "'}";
            return Content(msg.ToJson().ToString());

        }
        /// <summary>
        /// 退回评议
        /// 评定状态(0正在评定,1已评定,2被退回,3退回到评议)
        /// </summary>
        /// <param name="aptid">受理单id</param>
        /// <returns></returns>
        public ActionResult ReturnReview(Zor_Evaluate evaluate, string accpid)
        {
            BaseAnswer bar = new BaseAnswer();
            bar = Zor_Evaluate_Bll<dynamic>.ReturnReview(evaluate, accpid);
            return Content(bar.ToJson());
        }
        #endregion

        #region - 评议管理 -
        /// <summary>
        /// 评议管理列表
        /// create zhl by 2017.3.29  
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        public ActionResult Zor_Review(V_Zor_Review Model, int? index = 1, string where = null)
        {
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_Zor_Review> ReviewPage = Zor_Review_Bll<V_Zor_Review>.GetPageList(Model,pageIndex, out totalCount, where).AsQueryable().ToPagedList(0, 10) as PagedList<V_Zor_Review>;
            ReviewPage.TotalItemCount = totalCount;
            ReviewPage.CurrentPageIndex = (int)(index ?? 1);
            V_Zor_Review vr = new V_Zor_Review();
          
            vr.PageData = ReviewPage;
            return View(vr);
        }
        /// <summary>
        /// 推送提交至评定
        /// create zhl by 17.3.31
        /// </summary>
        /// <param name="review">评议对象</param>
        /// <returns>2--当前评议已推送-1操作失败1--操作成功的标识</returns>
        public ActionResult Review(Zor_Review review)
        {
            string messge = Zor_Review_Bll<dynamic>.Review(review);
            string msg = "{'AnswerMeg':'" + messge + "'}";
            return Content(msg.ToJson().ToString());

        }
        /// <summary>
        /// 退回至受理单
        /// 评议状态(0正在评议,1已评议,2被退回,3退回到受理单)
        /// </summary>
        /// <param name="aptid">受理单id</param>
        /// <returns></returns>
        public ActionResult ReturnAcceptance(Zor_Review review)
        {
            BaseAnswer bar = new BaseAnswer();
            bar = Zor_Review_Bll<dynamic>.ReturnAcceptance(review);
            return Content(bar.ToJson());
        }
        #endregion

        #region - 自然人管理 -
        /// <summary>
        /// 导出自然人列表
        /// create zhl by 17.3.27
        /// </summary>
        /// <param name="fields">要导出的列表字段集合</param>
        /// <returns>返回数据流</returns>
        [HttpPost]
        public FileResult ExportNaturalPerson(FormCollection form)
        {
            //this.hdnExcelarr.Value.Split(',');
            string fields = form["fields"];
            string where = form["where"];
            string[] str_arr = fields.Split(',');
            NoSortHashTable nameList = new NoSortHashTable();

            for (int i = 0; i < str_arr.Length; i++)
            {
                if (str_arr[i] != "")
                {
                    string[] item = str_arr[i].Split('|');
                    nameList.Add(item[0], item[1]);
                }
            }

            #region 拼接table

            System.Text.StringBuilder data = new System.Text.StringBuilder();
            if (nameList != null)
            {
                data.Append("<table cellspacing=\"0\" cellpadding=\"5\" rules=\"all\">");
                //写出列名
                data.Append("<tr style=\"font-weight: bold; white-space: nowrap;\">");


                foreach (string s in nameList.Keys)
                {
                    data.Append("<td>" + nameList[s] + "</td>");
                }
                data.Append("</tr>");

                List<V_Acceptance> list = Zor_NaturalPerson_Bll<V_Acceptance>.GetList((V_Acceptance)TempData["QueryConditions"], where);
                //写出数据
                foreach (V_Acceptance model in list)
                {
                    data.Append("<tr>");
                    foreach (string sm in nameList.Keys)
                    {
                        switch (sm)
                        {
                            case "Acceptance_TicketNumber": data.Append("<td style='vnd.ms-excel.numberformat:@'>" + model.Acceptance_TicketNumber.ToString() + "</td>"); ; break;
                            case "NatPer_Name": data.Append("<td>" + model.NatPer_Name + "</td>"); ; break;
                            case "NatPer_Phone": data.Append("<td>" + model.NatPer_Phone + "</td>"); ; break;
                            case "NatPer_IDNumber": data.Append("<td>" + model.NatPer_IDNumber + "</td>"); ; break;
                            case "Lease_StartTime": data.Append("<td>" + TimeHelper.TimeStampToDateTime(model.Lease_StartTime.ToString(), TimeHelper.ToTimeType.link_ymdt) + "</td>"); ; break;
                            case "Lease_EndTime": data.Append("<td>" + TimeHelper.TimeStampToDateTime(model.Lease_EndTime.ToString(), TimeHelper.ToTimeType.link_ymdt) + "</td>"); ; break;
                            case "Acceptance_TaxStartTime": data.Append("<td>" + TimeHelper.TimeStampToDateTime(model.Acceptance_TaxStartTime.ToString(), TimeHelper.ToTimeType.link_ymdt) + "</td>"); ; break;
                            case "Acceptance_TaxEndTime": data.Append("<td>" + TimeHelper.TimeStampToDateTime(model.Acceptance_TaxEndTime.ToString(), TimeHelper.ToTimeType.link_ymdt) + "</td>"); ; break;
                            case "Acceptance_TaxNumber": data.Append("<td style='vnd.ms-excel.numberformat:@'>" + model.Acceptance_TaxNumber.ToString() + "</td>"); ; break;
                            case "Tax": data.Append("<td>" + model.Tax*0.01 + "</td>"); ; break;
                            case "Hs_Proportion": data.Append("<td>" + model.Hs_Proportion.ToString() + "</td>"); ; break;
                            case "LeaseRent": data.Append("<td>" + model.LeaseRent*0.01+ "</td>"); ; break;
                            case "Csqx": data.Append("<td>" + model.Csqx + "</td>"); ; break;
                            case "AHA": data.Append("<td>" + model.AHA + "</td>"); ; break;
                            case "State": data.Append("<td>" + model.State + "</td>"); ; break;
                        }
                    }
                    data.Append("</tr>");
                }
                data.Append("</table>");
            }
            #endregion

            string sw = ExcelHelper.ExcelTemplate(data.ToString());

            string fileName = DateTime.Now.ToString("yyyyMMddHHmmss");
            // 写入到数据流
            return File(System.Text.Encoding.UTF8.GetBytes(sw.ToString()), "application/octet-stream", "自然人清单_" + fileName + ".xls");

        }
        /// <summary>
        /// 获取自然人任务列表
        /// create zhl by 2017.3.29  
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        public ActionResult Zor_NaturalPerson(V_Acceptance Model,int? index = 1, string where = null)
        {
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_Acceptance> AccPage = Zor_NaturalPerson_Bll<V_Acceptance>.GetPageList(Model,pageIndex, out totalCount, where).AsQueryable().ToPagedList(0, 10) as PagedList<V_Acceptance>;
            AccPage.TotalItemCount = totalCount;
            AccPage.CurrentPageIndex = (int)(index ?? 1);
            V_Acceptance vr = new V_Acceptance();
            vr.PageData = AccPage;
            TempData["QueryConditions"] = Model;//给导出数据传查询条件
            return View(vr);
        }
        /// <summary>
        /// 查询当前街道(根据当前部门ID)
        /// create zhl by 2017.3.29    
        /// </summary>      
        /// <param name="dt_Id">根据社区ID</param>
        /// <returns></returns>
        public ActionResult SelectStreetById()
        {
            List<Sys_Department> listNode = Zor_NaturalPerson_Bll<Sys_Department>.SelectStreetById();
            return Content(listNode.ToJson());
        }
        /// <summary>
        /// 查询所有街道(根据社区ID)
        /// create zhl by 2017.3.29    
        /// </summary>      
        /// <param name="dt_Id">根据社区ID</param>
        /// <returns></returns>
        public ActionResult SelectStreetByDtId(int dt_Id)
        {
            Sys_Department street = Zor_NaturalPerson_Bll<Sys_Department>.SelectStreet(dt_Id);
            return Content(street.Dt_ParentId.ToString());
        }
        /// <summary>
        /// 查询所有社区
        /// create zhl by 2017.3.28
        /// <param name="parentid">街道ID</param>
        /// </summary>
        /// <returns></returns>
        public ActionResult SelectCommunity(int parentid)
        {
            List<Sys_Department> listNode = Zor_NaturalPerson_Bll<Sys_Department>.SelectCommunity(parentid);

            return Content(listNode.ToJson());
        }

        /// <summary>
        /// 自然人管理-新增与修改
        /// create zhl by 17-3-30
        /// </summary>
        /// <param name="naturalPerson">自然人实体</param>
        /// <param name="lease">租赁实体</param>
        /// <param name="acceptance">受理单实体</param>
        /// <param name="tenant">租户实体</param>
        /// <param name="house">房屋实体</param>
        /// <param name="unitInfo">单元实体</param>
        /// <param name="Build">楼宇实体</param>
        /// <param name="leasestartTime">租赁开始时间</param>
        /// <param name="leaseendTime">租赁结束时间</param>
        /// <param name="taxstarttime">税金开始时间</param>
        /// <param name="taxendtime">税金结束时间</param>
        /// <returns> Succee = 1//成功 Failure = 2, //失败Error = 3 //异常</returns>
        public ActionResult AddAlterNaturalPerson(Zor_NaturalPerson naturalPerson, Zor_Lease lease, Zor_Acceptance acceptance, Zor_Tenant tenant, Zor_Hous house, Zor_UnitInfor unitInfo, Zor_Building Build, DateTime leasestartTime, DateTime leaseendTime, DateTime taxstarttime, DateTime taxendtime)
        {
            BaseAnswer bar = new BaseAnswer();
            if (acceptance.Acceptance_Id > 0)
                bar = Zor_NaturalPerson_Bll<dynamic>.UpdateNaturalPerson(naturalPerson, lease, acceptance, tenant, house, unitInfo, Build, leasestartTime, leaseendTime, taxstarttime, taxendtime);   //修改
            else
                bar = Zor_NaturalPerson_Bll<dynamic>.InsertNaturalPerson(naturalPerson, lease, acceptance, tenant, house, unitInfo, Build, leasestartTime, leaseendTime, taxstarttime, taxendtime);    //新增
            return Content(bar.ToJson());
        }
        /// <summary>
        /// 删除受理单
        /// create zhl by 17.3.27
        /// </summary>
        /// <param name="id">受理单id</param>
        /// <returns> Succee = 1//成功 Failure = 2, //失败Error = 3 //异常</returns>
        public ActionResult DeleteNaturalPerson(int AcceptanceId, int Lease_Id, int Hs_Id, int Uim_Id, int Bd_Id, int Hs_attributes)
        {
            BaseAnswer bar = Zor_NaturalPerson_Bll<dynamic>.DeleteNaturalPerson(AcceptanceId, Lease_Id, Hs_Id, Uim_Id, Bd_Id, Hs_attributes);
            return Content(bar.ToJson());

        }

        /// <summary>
        /// 推送
        /// create zhl by 17.3.30
        /// </summary>
        /// <param name="id">受理单id</param>
        /// <param name="acceptancestate">受理单状态</param>
        /// <returns>2--当前受理单已推送-1操作失败1--操作成功的标识</returns> 
        public ActionResult Push(int id, int acceptancestate, int dtid)
        {
            string messge = Zor_NaturalPerson_Bll<dynamic>.Push(id, acceptancestate, dtid);
            string msg = "{'AnswerMeg':'" + messge + "'}";
            return Content(msg.ToJson().ToString());

        }
        /// <summary>
        /// 推送并评议
        /// create zhl by 17.3.30
        /// </summary>
        /// <param name="ApeId">受理单id</param>
        /// <param name="propertytax">评议房屋税金</param>
        /// <param name="tax">评议税金</param>
        /// <param name="totaltax">评议计税总额</param>
        /// <param name="personaltax">评议个税</param>
        /// <param name="rentMoney">评议租金</param>
        /// <param name="acceptancestate">受理单状态</param>
        /// <param name="comment"></param>
        /// <returns>2--当前受理单已推送-1操作失败1--操作成功的标识</returns> 
        public ActionResult PushReview(int ApeId, int propertytax, int tax, int totaltax, int personaltax, int rentMoney, string reviewcomment, int acceptancestate, int dtid)
        {
            string messge = Zor_NaturalPerson_Bll<dynamic>.PushReview(ApeId, propertytax, tax, totaltax, personaltax, rentMoney, reviewcomment, acceptancestate, dtid);
            string msg = "{'AnswerMeg':'" + messge + "'}";
            return Content(msg.ToJson().ToString());

        }

        
        /// <summary>
        /// 获取地址
        /// </summary>
        /// <param name="NatPer_Name"></param>
        /// <param name="?"></param>
        /// <returns></returns>
        public ActionResult GetAcceptanceAddress(string NatPer_Name,string Tenant_Name)
        {
            List<string> listAddress = Zor_NaturalPerson_Bll<string>.GetAcceptanceAddress(NatPer_Name,Tenant_Name);
            if (listAddress.Count < 1)
            {
                listAddress.Add("西安市莲湖区");
            }
            return Content(listAddress.ToJson());
        }
        #endregion

        #region - 年度计划任务管理 -
        /// <summary>
        /// 获取年度计划任务列表
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        public ActionResult Zor_AnnualTask(V_Zor_AnnualTask Model, int? index = 1, string where = null)
         {
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_Zor_AnnualTask> AnnualTaskPage = Zor_AnnualTask_Bll<V_Zor_AnnualTask>.GetPageList(Model, pageIndex, out totalCount, where).AsQueryable().ToPagedList(0, 10) as PagedList<V_Zor_AnnualTask>;
            AnnualTaskPage.TotalItemCount = totalCount;
            AnnualTaskPage.CurrentPageIndex = (int)(index ?? 1);
            V_Zor_AnnualTask vr = new V_Zor_AnnualTask();
            vr.PageData = AnnualTaskPage;
            return View(vr);
        }
        /// <summary>
        /// 查询所有街道
        /// create zhl by 2017.3.27     
        /// </summary>
        /// <returns></returns>
        public ActionResult SelectStreet()
        {
            List<Sys_Department> listNode = Zor_AnnualTask_Bll<Sys_Department>.SelectStreet();         
            return Content(listNode.ToJson());
        }

        /// <summary>
        /// 年度计划任务管理-新增
        /// create zhl by 17.3.27
        /// </summary>
        /// <param name="task">年度计划任务对象</param>
        /// <returns>执行结果：1 成功 0失败</returns>
        public ActionResult AddAlterAnnualTask(Zor_AnnualTask task)
        {
            BaseAnswer bar = new BaseAnswer();
            if (task.At_Id > 0)
                bar = Zor_AnnualTask_Bll<dynamic>.UpdateAnnualTask(task);   //修改
            else
                bar = Zor_AnnualTask_Bll<dynamic>.InsertAnnualTask(task);   //新增
            return Content(bar.ToJson());
        }
        /// <summary>
        /// 删除年度计划任务
        /// create zhl by 17.3.27
        /// </summary>
        /// <param name="id">年度计划任务的id</param>
        /// <returns>1正常 返回0</returns>
        public ActionResult DeleteAnnualTask(int[] id)
        {
            BaseAnswer bar = Zor_AnnualTask_Bll<dynamic>.DeleteAnnualTask(id);
            return Content(bar.ToJson());

        }
        #endregion

        #region - 租户管理控制器 -

        /// <summary>
        /// 显示个人租户列表
        /// create zhl by 2017.3.24
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        public ActionResult Zor_TenantPersonal(V_Zor_TenantEnterprise Model, int? index = 1, string where = "Tenant_Type=1")
        {
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_Zor_TenantEnterprise> TenantPage = Zor_TenantEnterprise_Bll<V_Zor_TenantEnterprise>.GetPageList(Model, pageIndex, out totalCount, where).AsQueryable().ToPagedList(0, 10) as PagedList<V_Zor_TenantEnterprise>;
            TenantPage.TotalItemCount = totalCount;
            TenantPage.CurrentPageIndex = (int)(index ?? 1);
            V_Zor_TenantEnterprise vr = new V_Zor_TenantEnterprise();
            vr.PageData = TenantPage;
            TempData["QueryConditions"] = Model;//给导出数据传查询条件
            return View(vr);
        }
        /// <summary>
        /// 显示企业租户列表
        /// create zhl by 2017.3.24
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        public ActionResult Zor_TenantEnterprise(V_Zor_TenantEnterprise Model, int? index = 1, string where = "Tenant_Type=2")
        {
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_Zor_TenantEnterprise> TenantPage = Zor_TenantEnterprise_Bll<V_Zor_TenantEnterprise>.GetPageList(Model, pageIndex, out totalCount, where).AsQueryable().ToPagedList(0, 10) as PagedList<V_Zor_TenantEnterprise>;
            TenantPage.TotalItemCount = totalCount;
            TenantPage.CurrentPageIndex = (int)(index ?? 1);
            V_Zor_TenantEnterprise vr = new V_Zor_TenantEnterprise();
            vr.PageData = TenantPage;

            TempData["QueryConditions"] = Model;//给导出数据传查询条件
            return View(vr);
        }

        /// <summary>
        /// 查询行业
        ///  create zhl by 17-3-22
        /// </summary>
        /// <returns></returns>
        public ActionResult SelectIndustry()
        {
            List<Zor_CommonType> listNode = Zor_TenantEnterprise_Bll<Zor_CommonType>.SelectIndustry(4);

            return Content(listNode.ToJson());
        }
        /// <summary>
        /// 删除租户信息
        /// create zhl by 2017.3.24
        /// </summary>
        /// <param name="Tenant_Id">租户的id</param>
        /// <returns>1正常 返回0</returns>
        public ActionResult DeleteTenant(int[] id)
        {
            BaseAnswer bar = Zor_TenantEnterprise_Bll<dynamic>.DeleteTenant(id);
            return Content(bar.ToJson());
        }

        /// <summary>
        /// 新增/修改租户
        /// create zhl by 2017.3.24
        /// </summary>
        /// <param name="Tenant">租户对象</param>
        /// <returns>执行结果消息</returns>
        [HttpPost]
        public ActionResult AddAlterTenant(Zor_Tenant tenant)
        {
            BaseAnswer bar = new BaseAnswer();
            if (tenant.Tenant_Id > 0)
                bar = Zor_TenantEnterprise_Bll<dynamic>.UpdateTenant(tenant);   //修改
            else
                bar = Zor_TenantEnterprise_Bll<dynamic>.InsertTenant(tenant);   //新增
            return Content(bar.ToJson());
        }

        /// <summary>
        /// 导出个人租户列表
        /// create zhl by 17.4.1
        /// </summary>
        /// <param name="fields">要导出的列表字段集合</param>
        /// <returns>返回数据流</returns>
        [HttpPost]
        public FileResult ExportTenantPerson(FormCollection form)
        {
            string fields = form["fields"];
            string where = form["where"];
            string[] str_arr = fields.Split(',');
            NoSortHashTable nameList = new NoSortHashTable();

            for (int i = 0; i < str_arr.Length; i++)
            {
                if (str_arr[i] != "")
                {
                    string[] item = str_arr[i].Split('|');
                    nameList.Add(item[0], item[1]);
                }
            }

            #region 拼接table

            System.Text.StringBuilder data = new System.Text.StringBuilder();
            if (nameList != null)
            {
                data.Append("<table cellspacing=\"0\" cellpadding=\"5\" rules=\"all\">");
                //写出列名
                data.Append("<tr style=\"font-weight: bold; white-space: nowrap;\">");


                foreach (string s in nameList.Keys)
                {
                    data.Append("<td>" + nameList[s] + "</td>");
                }
                data.Append("</tr>");

                List<V_Zor_TenantEnterprise> list = Zor_TenantEnterprise_Bll<V_Zor_TenantEnterprise>.GetList((V_Zor_TenantEnterprise)TempData["QueryConditions"], where);
                //写出数据
                foreach (V_Zor_TenantEnterprise model in list)
                {
                    data.Append("<tr>");
                    foreach (string sm in nameList.Keys)
                    {
                        switch (sm)
                        {
                            case "Tenant_Name": data.Append("<td>" + model.Tenant_Name + "</td>"); break;
                            case "sex": data.Append("<td>" + model.sex + "</td>"); break;
                            case "Tenant_IDNumber": data.Append("<td style='vnd.ms-excel.numberformat:@>" + model.Tenant_IDNumber + "</td>"); break;
                            case "Tenant_Phone": data.Append("<td style='vnd.ms-excel.numberformat:@>" + model.Tenant_Phone + "</td>"); break;
                            case "Tenant_Company": data.Append("<td>" + model.Tenant_Company + "</td>"); break;
                            case "Tenant_Number": data.Append("<td>" + model.Tenant_Number + "</td>"); break;
                            case "nature": data.Append("<td>" + model.nature + "</td>"); break;
                            case "Tenant_Code": data.Append("<td>" + model.Tenant_Code + "</td>"); break;
                        }
                    }
                    data.Append("</tr>");
                }
                data.Append("</table>");
            }
            #endregion

            string sw = ExcelHelper.ExcelTemplate(data.ToString());

            string fileName = DateTime.Now.ToString("yyyyMMddHHmmss");
            // 写入到数据流
            return File(System.Text.Encoding.UTF8.GetBytes(sw.ToString()), "application/octet-stream", "个人租户清单_" + fileName + ".xls");

        }

        /// <summary>
        /// 导出企业租户列表
        /// create zhl by 17.4.1
        /// </summary>
        /// <param name="fields">要导出的列表字段集合</param>
        /// <returns>返回数据流</returns>
        [HttpPost]
        public FileResult ExportTenantEnterprise(FormCollection form)
        {
            string fields = form["fields"];
            string where = form["where"];
            string[] str_arr = fields.Split(',');
            NoSortHashTable nameList = new NoSortHashTable();

            for (int i = 0; i < str_arr.Length; i++)
            {
                if (str_arr[i] != "")
                {
                    string[] item = str_arr[i].Split('|');
                    nameList.Add(item[0], item[1]);
                }
            }

            #region 拼接table

            System.Text.StringBuilder data = new System.Text.StringBuilder();
            if (nameList != null)
            {
                data.Append("<table cellspacing=\"0\" cellpadding=\"5\" rules=\"all\">");
                //写出列名
                data.Append("<tr style=\"font-weight: bold; white-space: nowrap;\">");


                foreach (string s in nameList.Keys)
                {
                    data.Append("<td>" + nameList[s] + "</td>");
                }
                data.Append("</tr>");

                List<V_Zor_TenantEnterprise> list = Zor_TenantEnterprise_Bll<V_Zor_TenantEnterprise>.GetList((V_Zor_TenantEnterprise)TempData["QueryConditions"], where);
                //写出数据
                foreach (V_Zor_TenantEnterprise model in list)
                {
                    data.Append("<tr>");
                    foreach (string sm in nameList.Keys)
                    {
                        switch (sm)
                        {
                            case "Tenant_Name": data.Append("<td>" + model.Tenant_Name + "</td>"); break;
                            case "Tenant_ProprietorPhone": data.Append("<td>" + model.Tenant_ProprietorPhone + "</td>"); break;
                            case "istaxregistration": data.Append("<td>" + model.istaxregistration + "</td>"); break;
                            case "Tenant_TaxRegistrationNum": data.Append("<td>" + model.Tenant_TaxRegistrationNum + "</td>"); break;
                            case "Tenant_Code": data.Append("<td>" + model.Tenant_Code + "</td>"); break;
                            case "Tenant_LegalPerson": data.Append("<td>" + model.Tenant_LegalPerson + "</td>"); break;
                            case "Tenant_TaxAuthority": data.Append("<td>" + model.Tenant_TaxAuthority + "</td>"); break;
                            case "Tenant_ScopeBusiness": data.Append("<td>" + model.Tenant_ScopeBusiness + "</td>"); break;
                            case "industry": data.Append("<td>" + model.industry + "</td>"); break;
                        }
                    }
                    data.Append("</tr>");
                }
                data.Append("</table>");
            }
            #endregion

            string sw = ExcelHelper.ExcelTemplate(data.ToString());

            string fileName = DateTime.Now.ToString("yyyyMMddHHmmss");
            // 写入到数据流
            return File(System.Text.Encoding.UTF8.GetBytes(sw.ToString()), "application/octet-stream", "企业租户清单_" + fileName + ".xls");

        }

        #endregion

        #region - 街道信息管理 -
        /// <summary>
        /// 导出街道信息列表
        /// create Light by 2017/04/06
        /// </summary>
        /// <param name="buildingMeg">要导出的列表字段集合</param>
        /// <returns>返回数据流</returns>
        [HttpPost]
        public FileResult ExportStreet(FormCollection form)
        {
            string buildingMeg = form["buildingMeg"];
            string where = form["where"];
            string[] str_arr = buildingMeg.Split(',');
            NoSortHashTable nameList = new NoSortHashTable();

            for (int i = 0; i < str_arr.Length; i++)
            {
                if (str_arr[i] != "")
                {
                    string[] item = str_arr[i].Split('|');
                    nameList.Add(item[0], item[1]);
                }
            }

            #region 拼接table

            System.Text.StringBuilder data = new System.Text.StringBuilder();
            if (nameList != null)
            {
                data.Append("<table cellspacing=\"0\" cellpadding=\"5\" rules=\"all\">");
                //写出列名
                data.Append("<tr style=\"font-weight: bold; white-space: nowrap;\">");
                foreach (string s in nameList.Keys)
                {
                    data.Append("<td>" + nameList[s] + "</td>");
                }
                data.Append("</tr>");
                List<V_Zor_Building> list = Zor_Building_Bll<V_Zor_Building>.GetStreetList((V_Zor_Building)TempData["QueryConditions"], where);
                //写出数据
                foreach (V_Zor_Building model in list)
                {
                    data.Append("<tr>");
                    foreach (string sm in nameList.Keys)
                    {
                        switch (sm)
                        {
                            case "Dt_Name": data.Append("<td style='vnd.ms-excel.numberformat:@'>" + model.Dt_Name + "</td>"); ; break;
                            case "Bd_Name": data.Append("<td>" + model.Bd_Name + "</td>"); ; break;
                            case "Bd_Aname": data.Append("<td>" + model.Bd_Aname + "</td>"); ; break;
                            case "Sex": data.Append("<td>" + model.Sex + "</td>"); ; break;
                            case "Bd_IDNumber": data.Append("<td style='vnd.ms-excel.numberformat:@'>" + model.Bd_IDNumber + "</td>"); ; break;
                            case "Bd_Telephone": data.Append("<td>" + model.Bd_Telephone + "</td>"); ; break;
                            case "Bd_CreateDate": data.Append("<td>" + TimeHelper.TimeStampToDateTime(model.Bd_CreateDate.ToString(), TimeHelper.ToTimeType.link_ymdt) + "</td>"); ; break;

                        }
                    }
                    data.Append("</tr>");
                }
                data.Append("</table>");
            }
            #endregion

            string sw = ExcelHelper.ExcelTemplate(data.ToString());

            string fileName = DateTime.Now.ToString("yyyyMMddHHmmss");
            // 写入到数据流
            return File(System.Text.Encoding.UTF8.GetBytes(sw.ToString()), "application/octet-stream", "街道信息清单_" + fileName + ".xls");

        }

        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        public ActionResult Zor_Street(Models.Base.V_Zor_Building model, int? index = 1, string where = null)
        {

            int totalCount = 0;
            int pageIndex = index ?? 1;

         
            PagedList<V_Zor_Building> zvPager = Zor_Street_Bll<V_Zor_Building>.GetPageList(model,pageIndex, out totalCount, where).AsQueryable().ToPagedList(0, 10) as PagedList<V_Zor_Building>;

            zvPager.TotalItemCount = totalCount;
            zvPager.CurrentPageIndex = (int)(index ?? 1);

            V_Zor_Building vb = new V_Zor_Building();
            vb.PageData = zvPager;
            TempData["QueryConditions"] = model;//给导出数据传查询条件
            return View(vb);
        }

        /// <summary>
        /// 新增/修改街道
        /// </summary>
        /// <param name="street">街道对象</param>
        /// <returns>执行结果消息</returns>
        [HttpPost]
        public ActionResult AddStreet(Zor_Building street)
        {
            BaseAnswer bar = new BaseAnswer();
            if (street.Bd_Id > 0)
                bar = Zor_Street_Bll<dynamic>.UpdateBuilding(street);   //修改
            else
                bar = Zor_Street_Bll<dynamic>.InsertBuilding(street, 1);   //新增

            return Content(bar.ToJson());

        }

        /// <summary>
        /// 删除街道信息
        /// </summary>
        /// <param name="Street_Id">选中街道的id</param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult DeleteStreet(int[] id)
        {
            BaseAnswer bar = Zor_Street_Bll<dynamic>.DeleteBuilding(id);
            return Content(bar.ToJson());
        }


        #endregion

        #region - 门牌信息管理 -

        /// <summary>
        /// 导出门牌信息列表
        /// create light by 2017/04/06
        /// </summary>
        /// <param name="InformationMeg">要导出的列表字段集合</param>
        /// <returns>返回数据流</returns>
        [HttpPost]
        public FileResult ExportDoorp(FormCollection form)
        {
            string InformationMeg = form["InformationMeg"];
            string where = form["where"];
            string[] str_arr = InformationMeg.Split(',');
            NoSortHashTable nameList = new NoSortHashTable();

            for (int i = 0; i < str_arr.Length; i++)
            {
                if (str_arr[i] != "")
                {
                    string[] item = str_arr[i].Split('|');
                    nameList.Add(item[0], item[1]);
                }
            }

            #region 拼接table

            System.Text.StringBuilder data = new System.Text.StringBuilder();
            if (nameList != null)
            {
                data.Append("<table cellspacing=\"0\" cellpadding=\"5\" rules=\"all\">");
                //写出列名
                data.Append("<tr style=\"font-weight: bold; white-space: nowrap;\">");


                foreach (string s in nameList.Keys)
                {
                    data.Append("<td>" + nameList[s] + "</td>");
                }
                data.Append("</tr>");

                List<V_UnitInformation> list = Zor_UnitInformation_Bll<V_UnitInformation>.GetDoorpList((V_UnitInformation)TempData["QueryConditions"], where);
                //写出数据
                foreach (V_UnitInformation model in list)
                {
                    data.Append("<tr>");
                    foreach (string sm in nameList.Keys)
                    {
                        switch (sm)
                        {
                            case "Bd_Name": data.Append("<td>" + model.Bd_Name + "</td>"); ; break;
                            case "Uim_Name": data.Append("<td>" + model.Uim_Name + "</td>"); ; break;
                            case "Uim_CreateDate": data.Append("<td>" + TimeHelper.TimeStampToDateTime(model.Uim_CreateDate.ToString(), TimeHelper.ToTimeType.link_ymdt) + "</td>"); ; break;

                        }
                    }
                    data.Append("</tr>");
                }
                data.Append("</table>");
            }
            #endregion

            string sw = ExcelHelper.ExcelTemplate(data.ToString());

            string fileName = DateTime.Now.ToString("yyyyMMddHHmmss");
            // 写入到数据流
            return File(System.Text.Encoding.UTF8.GetBytes(sw.ToString()), "application/octet-stream", "门牌信息清单_" + fileName + ".xls");

        }



        /// <summary>
        /// 加载数据
        /// </summary>  
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>

        public ActionResult Zor_Doorplate(Models.Base.V_UnitInformation model, int? index = 1, string where = null)
        {
            var Dt_Id = RequestSession.GetSessionUser().DT_Id;
            int totalCount = 0;
            int pageIndex = index ?? 1;
            var sqlSurch = string.Empty;
            if (model.Bd_Name != null)
            {
                sqlSurch += " Bd_Name like '%" + model.Bd_Name + "%' and ";
            }

            if (model.Uim_Name != null)
            {
                sqlSurch += " Uim_Name like '%" + model.Uim_Name + "%' and ";
            }

            sqlSurch += " Uim_Flage = 1 and Dt_Id = " + Dt_Id + "";
            PagedList<V_UnitInformation> zvPager = Zor_UnitInformation_Bll<V_UnitInformation>.GetPageList(pageIndex, out totalCount, sqlSurch).AsQueryable().ToPagedList(0, 10) as PagedList<V_UnitInformation>;
            zvPager.TotalItemCount = totalCount;
            zvPager.CurrentPageIndex = (int)(index ?? 1);

            V_UnitInformation vb = new V_UnitInformation();
            vb.PageData = zvPager;
            TempData["QueryConditions"] = model;//给导出数据传查询条件
            return View(vb);
        }

        /// <summary>
        ///  新增/修改门牌
        ///</summary>
        /// <param name="doorplate">门牌对象</param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult AddDoorplate(Zor_UnitInfor doorplate)
        {
            BaseAnswer bar = new BaseAnswer();
            if (doorplate.Uim_Id > 0)
                bar = Zor_UnitInformation_Bll<dynamic>.UpdateUnitInformation(doorplate);   //修改
            else
                bar = Zor_UnitInformation_Bll<dynamic>.InsertUnitInformation(doorplate, 1);   //新增

            return Content(bar.ToJson());

        }


        /// <summary>
        /// 删除门牌信息
        /// </summary>
        /// <param name="Doorplate_Id">选中门牌的id</param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult DeleteDoorplate(int[] id)
        {
            BaseAnswer bar = Zor_UnitInformation_Bll<dynamic>.DeleteUnitInformation(id);
            return Content(bar.ToJson());
        }

        /// <summary>
        /// 获取所属街道名称
        /// </summary>
        /// <returns></returns>
        public ActionResult GetBdName()
        {
            List<Zor_Building> listBdName = Zor_UnitInformation_Bll<Zor_Building>.GetBdName();
            return Content(listBdName.ToJson());
        }

        #endregion

        #region - 商铺信息管理 -
        /// <summary>
        /// 导出楼宇信息列表
        /// create light by 2017/04/06
        /// </summary>
        /// <param name="HousingMeg">要导出的列表字段集合</param>
        /// <returns>返回数据流</returns>
        [HttpPost]
        public FileResult ExportShops(FormCollection form)
        {
            string HousingMeg = form["HousingMeg"];
            string where = form["where"];
            string[] str_arr = HousingMeg.Split(',');
            NoSortHashTable nameList = new NoSortHashTable();

            for (int i = 0; i < str_arr.Length; i++)
            {
                if (str_arr[i] != "")
                {
                    string[] item = str_arr[i].Split('|');
                    nameList.Add(item[0], item[1]);
                }
            }

            #region 拼接table

            System.Text.StringBuilder data = new System.Text.StringBuilder();
            if (nameList != null)
            {
                data.Append("<table cellspacing=\"0\" cellpadding=\"5\" rules=\"all\">");
                //写出列名
                data.Append("<tr style=\"font-weight: bold; white-space: nowrap;\">");


                foreach (string s in nameList.Keys)
                {
                    data.Append("<td>" + nameList[s] + "</td>");
                }
                data.Append("</tr>");

                List<V_Zor_Hous> list = Zor_Housing_Bll<V_Zor_Hous>.GetShopsList((V_Zor_Hous)TempData["QueryConditions"], where);
                //写出数据
                foreach (V_Zor_Hous model in list)
                {
                    data.Append("<tr>");
                    foreach (string sm in nameList.Keys)
                    {
                        switch (sm)
                        {
                            case "Hs_Number": data.Append("<td>" + model.Hs_Number.ToString() + "</td>"); ; break;
                            case "Bd_Name": data.Append("<td>" + model.Bd_Name + "</td>"); ; break;
                            case "Uim_Name": data.Append("<td style='vnd.ms-excel.numberformat:@'>" + model.Uim_Name + "</td>"); ; break;
                            case "NatPer_Name": data.Append("<td>" + model.NatPer_Name + "</td>"); ; break;
                            case "NatPer_IDNumber": data.Append("<td style='vnd.ms-excel.numberformat:@'>" + model.NatPer_IDNumber + "</td>"); ; break;
                            case "NatPer_Phone": data.Append("<td>" + model.NatPer_Phone + "</td>"); ; break;
                            case "NatSex": data.Append("<td>" + model.NatSex + "</td>"); ; break;
                            case "HousUse": data.Append("<td>" + model.HousUse + "</td>"); ; break;
                            case "Hs_Proportion": data.Append("<td style='vnd.ms-excel.numberformat:@'>" + model.Hs_Proportion.ToString() + "</td>"); ; break;
                            case "Shop_Longitude": data.Append("<td>" + model.Shop_Longitude + "</td>"); ; break;
                            case "Shop_Latitude": data.Append("<td>" + model.Shop_Latitude + "</td>"); ; break;
                            case "TaxeMode": data.Append("<td>" + model.TaxeMode + "</td>"); ; break;
                            case "Hs_CreateTime": data.Append("<td>" + TimeHelper.TimeStampToDateTime(model.Hs_CreateTime.ToString(), TimeHelper.ToTimeType.link_ymdt) + "</td>"); ; break;
                            case "attribute": data.Append("<td>" + model.Attribute + "</td>"); ; break;
                            case "Cqsx": data.Append("<td>" + model.Cqsx + "</td>"); ; break;
                        }
                    }
                    data.Append("</tr>");
                }
                data.Append("</table>");
            }
            #endregion

            string sw = ExcelHelper.ExcelTemplate(data.ToString());

            string fileName = DateTime.Now.ToString("yyyyMMddHHmmss");
            // 写入到数据流
            return File(System.Text.Encoding.UTF8.GetBytes(sw.ToString()), "application/octet-stream", "商铺信息清单_" + fileName + ".xls");

        }

        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
    
        public ActionResult Zor_Shops(Models.Base.V_Zor_Hous model, int? index = 1, string where = null)
        {
            var Dt_Id = RequestSession.GetSessionUser().DT_Id;
            int totalCount = 0;
            int pageIndex = index ?? 1;
            var sqlSurch = string.Empty;

            if (model.Hs_Number != null)
            {
                sqlSurch += " Hs_Number like '%" + model.Hs_Number + "%' and ";
            }

            if (model.Bd_Name != null)
            {
                sqlSurch += " Bd_Name like '%" + model.Bd_Name + "%' and ";
            }
            if (model.Uim_Name != null)
            {
                sqlSurch += " Uim_Name like '%" + model.Uim_Name + "%' and ";
            }
            if (model.NatPer_Name != null)
            {
                sqlSurch += " NatPer_Name like '%" + model.NatPer_Name + "%' and ";
            }
            if (model.NatPer_IDNumber != null)
            {
                sqlSurch += " NatPer_IDNumber like '%" + model.NatPer_IDNumber + "%' and ";
            }
            if (model.NatPer_Phone != null)
            {
                sqlSurch += " NatPer_Phone like '%" + model.NatPer_Phone + "%' and ";
            }
            if (model.Hs_Proportion != 0)
            {
                sqlSurch += " Hs_Proportion like '%" + model.Hs_Proportion + "%' and ";
            }
            if (model.Shop_Longitude != null)
            {
                sqlSurch += " Shop_Longitude like '%" + model.Shop_Longitude + "%' and ";
            }
            if (model.Shop_Latitude != null)
            {
                sqlSurch += " Shop_Latitude like '%" + model.Shop_Latitude + "%' and ";
            }
            if (model.Attribute != null)
            {
                sqlSurch += " Attribute like '%" + model.Attribute + "%' and ";
            }

            sqlSurch += " Hs_Flage = 1 and Dt_Id = " + Dt_Id + "";
            PagedList<V_Zor_Hous> zvPager = Zor_Shops_Bll<V_Zor_Hous>.GetPageList(pageIndex, out totalCount, sqlSurch).AsQueryable().ToPagedList(0, 10) as PagedList<V_Zor_Hous>;
            zvPager.TotalItemCount = totalCount;
            zvPager.CurrentPageIndex = (int)(index ?? 1);

            V_Zor_Hous vb = new V_Zor_Hous();
            vb.PageData = zvPager;
            TempData["QueryConditions"] = model;//给导出数据传查询条件
            return View(vb);
        }

        /// <summary>
        /// 新增/修改商铺
        /// </summary>
        /// <param name="housing">房屋对象</param>
        /// <returns>执行结果消息</returns>
        [HttpPost]
        public ActionResult AddShops(V_Zor_Hous housing, Zor_NaturalPerson naturalPerson)
        {
            BaseAnswer bar = new BaseAnswer();
            if (housing.Hs_Id > 0)
                bar = Zor_Shops_Bll<dynamic>.UpdateHous(housing, naturalPerson);   //修改
            else
                bar = Zor_Shops_Bll<dynamic>.InsertHous(housing, 1, naturalPerson);   //新增


            return Content(bar.ToJson());

        }



        /// <summary>
        /// 删除商铺信息
        /// </summary>
        /// <param name="id">选中房屋的id</param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult DeleteShops(int[] id)
        {
            BaseAnswer bar = Zor_Shops_Bll<dynamic>.DeleteHous(id);
            return Content(bar.ToJson());
        }


       

        /// <summary>
        /// 查询所有街道
        /// create Light by 2017.4.5 
        /// </summary>
        /// <returns></returns>
        public ActionResult SelectBdName()
        {
            List<Zor_Building> listNode = Zor_Shops_Bll<Zor_Building>.SelectBdName();
            return Content(listNode.ToJson());
        }

        /// <summary>
        /// 查询当前街道下的门牌
        /// create light by 2017.4.5     
        /// </summary>
        /// <returns></returns>
        public ActionResult GetUimName(int id)
        {
            List<Zor_UnitInfor> listNode = Zor_Shops_Bll<Zor_UnitInfor>.GetUimName(id);

            return Content(listNode.ToJson());
        }

        #endregion

        #region - 楼宇信息管理 -
        /// <summary>
        /// 导出楼宇信息列表
        /// create 刘云飞 by 2017/04/06
        /// </summary>
        /// <param name="buildingMeg">要导出的列表字段集合</param>
        /// <returns>返回数据流</returns>
        [HttpPost]
        public FileResult ExportBuilding(FormCollection form)
        {
            //this.hdnExcelarr.Value.Split(',');
            string buildingMeg = form["buildingMeg"];
            string where = form["where"];
            string[] str_arr = buildingMeg.Split(',');
            NoSortHashTable nameList = new NoSortHashTable();

            for (int i = 0; i < str_arr.Length; i++)
            {
                if (str_arr[i] != "")
                {
                    string[] item = str_arr[i].Split('|');
                    nameList.Add(item[0], item[1]);
                }
            }

            #region 拼接table

            System.Text.StringBuilder data = new System.Text.StringBuilder();
            if (nameList != null)
            {
                data.Append("<table cellspacing=\"0\" cellpadding=\"5\" rules=\"all\">");
                //写出列名
                data.Append("<tr style=\"font-weight: bold; white-space: nowrap;\">");


                foreach (string s in nameList.Keys)
                {
                    data.Append("<td>" + nameList[s] + "</td>");
                }
                data.Append("</tr>");

                List<V_Zor_Building> list = Zor_Building_Bll<V_Zor_Building>.GetList((V_Zor_Building)TempData["QueryConditions"], where);
                //写出数据
                foreach (V_Zor_Building model in list)
                {
                    data.Append("<tr>");
                    foreach (string sm in nameList.Keys)
                    {
                        switch (sm)
                        {
                            case "Dt_Name": data.Append("<td style='vnd.ms-excel.numberformat:@'>" + model.Dt_Name + "</td>"); ; break;
                            case "Bd_Name": data.Append("<td>" + model.Bd_Name + "</td>"); ; break;
                            case "Bd_Ground": data.Append("<td>" + model.Bd_Ground + "</td>"); ; break;
                            case "Bd_Underground": data.Append("<td style='vnd.ms-excel.numberformat:@'>" + model.Bd_Underground + "</td>"); ; break;
                            case "Bd_Longitude": data.Append("<td>" + model.Bd_Longitude.ToString() + "</td>"); ; break;
                            case "Bd_Latitude": data.Append("<td>" + model.Bd_Latitude.ToString() + "</td>"); ; break;
                            case "Bd_Aname": data.Append("<td>" + model.Bd_Aname + "</td>"); ; break;
                            case "Sex": data.Append("<td>" + model.Sex + "</td>"); ; break;
                            case "Bd_IDNumber": data.Append("<td style='vnd.ms-excel.numberformat:@'>" + model.Bd_IDNumber + "</td>"); ; break;
                            case "Bd_Telephone": data.Append("<td>" + model.Bd_Telephone + "</td>"); ; break;
                            case "Bd_CreateDate": data.Append("<td>" + TimeHelper.TimeStampToDateTime(model.Bd_CreateDate.ToString(), TimeHelper.ToTimeType.link_ymdt) + "</td>"); ; break;
                        }
                    }
                    data.Append("</tr>");
                }
                data.Append("</table>");
            }
            #endregion

            string sw = ExcelHelper.ExcelTemplate(data.ToString());

            string fileName = DateTime.Now.ToString("yyyyMMddHHmmss");
            // 写入到数据流
            return File(System.Text.Encoding.UTF8.GetBytes(sw.ToString()), "application/octet-stream", "楼宇信息清单_" + fileName + ".xls");

        }

        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        public ActionResult Zor_Building(V_Zor_Building model,int? index = 1, string where = null)
        {
            int totalCount = 0;
            int pageIndex = index ?? 1;
            
            PagedList<V_Zor_Building> zvPager = Zor_Building_Bll<V_Zor_Building>.GetPageList(model,pageIndex, out totalCount, where).AsQueryable().ToPagedList(0, 10) as PagedList<V_Zor_Building>;
            zvPager.TotalItemCount = totalCount;
            zvPager.CurrentPageIndex = (int)(index ?? 1);

            V_Zor_Building vb = new V_Zor_Building();
            vb.PageData = zvPager;
            TempData["QueryConditions"] = model;//给导出数据传查询条件
            return View(vb);
        }

        /// <summary>
        /// 新增/修改楼宇
        /// </summary>
        /// <param name="building">楼宇对象</param>
        /// <returns>执行结果消息</returns>
        [HttpPost]
        public ActionResult AddBuilding(Zor_Building building)
        {
            BaseAnswer bar = new BaseAnswer();

            if (building.Bd_Id > 0)
                bar = Zor_Building_Bll<dynamic>.UpdateBuilding(building);   //修改
            else
                bar = Zor_Building_Bll<dynamic>.InsertBuilding(building, 2);   //新增

            return Content(bar.ToJson());

        }


        /// <summary>
        /// 删除楼宇信息
        /// </summary>
        /// <param name="Bd_Id">选中楼宇的id</param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult DeleteBuilding(int[] id)
        {
            BaseAnswer bar = Zor_Building_Bll<dynamic>.DeleteBuilding(id);
            return Content(bar.ToJson());
        }

        /// <summary>
        /// 获取所属部门名称
        /// </summary>
        /// <returns></returns>
        public ActionResult GetDtName()
        {
            List<Sys_Department> listDtName = Zor_Building_Bll<Sys_Department>.GetDtName();
            return Content(listDtName.ToJson());
        }

        #endregion

        #region - 单元信息管理 -

        /// <summary>
        /// 导出单元信息列表
        /// create 刘云飞 by 2017/04/06
        /// </summary>
        /// <param name="InformationMeg">要导出的列表字段集合</param>
        /// <returns>返回数据流</returns>
        [HttpPost]
        public FileResult ExportUnitInfor(FormCollection form)
        {
            //this.hdnExcelarr.Value.Split(',');
            string InformationMeg = form["InformationMeg"];
            string where = form["where"];
            string[] str_arr = InformationMeg.Split(',');
            NoSortHashTable nameList = new NoSortHashTable();

            for (int i = 0; i < str_arr.Length; i++)
            {
                if (str_arr[i] != "")
                {
                    string[] item = str_arr[i].Split('|');
                    nameList.Add(item[0], item[1]);
                }
            }

            #region 拼接table

            System.Text.StringBuilder data = new System.Text.StringBuilder();
            if (nameList != null)
            {
                data.Append("<table cellspacing=\"0\" cellpadding=\"5\" rules=\"all\">");
                //写出列名
                data.Append("<tr style=\"font-weight: bold; white-space: nowrap;\">");


                foreach (string s in nameList.Keys)
                {
                    data.Append("<td>" + nameList[s] + "</td>");
                }
                data.Append("</tr>");

                List<V_UnitInformation> list = Zor_UnitInformation_Bll<V_UnitInformation>.GetList(where);
                //写出数据
                foreach (V_UnitInformation model in list)
                {
                    data.Append("<tr>");
                    foreach (string sm in nameList.Keys)
                    {
                        switch (sm)
                        {
                            case "Bd_Name": data.Append("<td>" + model.Bd_Name + "</td>"); ; break;
                            case "Uim_Name": data.Append("<td>" + model.Uim_Name + "</td>"); ; break;
                            case "Uim_BuildStructure": data.Append("<td>" + model.Uim_BuildStructure + "</td>"); ; break;
                            case "Uim_CreateDate": data.Append("<td>" + TimeHelper.TimeStampToDateTime(model.Uim_CreateDate.ToString(), TimeHelper.ToTimeType.link_ymdt) + "</td>"); ; break;

                        }
                    }
                    data.Append("</tr>");
                }
                data.Append("</table>");
            }
            #endregion

            string sw = ExcelHelper.ExcelTemplate(data.ToString());

            string fileName = DateTime.Now.ToString("yyyyMMddHHmmss");
            // 写入到数据流
            return File(System.Text.Encoding.UTF8.GetBytes(sw.ToString()), "application/octet-stream", "单元信息清单_" + fileName + ".xls");

        }



        /// <summary>
        /// 单元信息
        /// create by Guoph at 2017.3.24
        /// </summary>
        /// <param name="index"></param>
        /// <param name="where"></param>
        /// <returns></returns>
        public ActionResult Zor_UnitInformation(int? index = 1, string where = null)
        {
            var uid = RequestSession.GetSessionUser().User_Id;
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_UnitInformation> rsPager = Zor_UnitInformation_Bll<V_UnitInformation>.GetPageList(pageIndex, out totalCount, " Uim_Flage = 2 and User_Id = " + uid + " or  Dt_Id = " + RequestSession.GetSessionUser().DT_Id + " and Uim_Flage = 2").AsQueryable().ToPagedList(0, 10) as PagedList<V_UnitInformation>;

            rsPager.TotalItemCount = totalCount;
            rsPager.CurrentPageIndex = (int)(index ?? 1);

            V_UnitInformation vr = new V_UnitInformation();
            vr.PageData = rsPager;
            return View(vr);
        }

        /// <summary>
        /// 获取楼宇下拉菜单
        /// </summary>
        /// <returns></returns>
        public ActionResult ListBuilding()
        {
            List<Zor_Building> lstBuilding = Zor_UnitInformation_Bll<Zor_Building>.GetListBuilding();
            return Content(lstBuilding.ToJson());
        }

        /// <summary>
        /// 新增/修改楼宇信息
        /// </summary>
        /// <param name="unitInformation">楼宇信息</param>
        /// <returns></returns>
        public ActionResult AddUnitInformation(Zor_UnitInfor unitInformation)
        {
            BaseAnswer bar = new BaseAnswer();
            if (unitInformation.Uim_Id > 0)
                bar = Zor_UnitInformation_Bll<dynamic>.UpdateUnitInformation(unitInformation);   //修改
            else
                bar = Zor_UnitInformation_Bll<dynamic>.InsertUnitInformation(unitInformation, 2);   //新增

            return Content(bar.ToJson());
        }

        /// <summary>
        /// 单元信息删除
        /// </summary>
        /// <param name="id">单元信息ID</param>
        /// <returns></returns>
        public ActionResult DeleteUnitInformation(int[] id)
        {
            BaseAnswer bar = Zor_UnitInformation_Bll<dynamic>.DeleteUnitInformation(id);
            return Content(bar.ToJson());
        }


        #endregion

        #region - 房屋信息管理 -

        /// <summary>
        /// 导出楼宇信息列表
        /// create 刘云飞 by 2017/04/06
        /// </summary>
        /// <param name="HousingMeg">要导出的列表字段集合</param>
        /// <returns>返回数据流</returns>
        [HttpPost]
        public FileResult ExportHousing(FormCollection form)
        {
            string HousingMeg = form["HousingMeg"];
            string where = form["where"];
            string[] str_arr = HousingMeg.Split(',');
            NoSortHashTable nameList = new NoSortHashTable();

            for (int i = 0; i < str_arr.Length; i++)
            {
                if (str_arr[i] != "")
                {
                    string[] item = str_arr[i].Split('|');
                    nameList.Add(item[0], item[1]);
                }
            }

            #region 拼接table

            System.Text.StringBuilder data = new System.Text.StringBuilder();
            if (nameList != null)
            {
                data.Append("<table cellspacing=\"0\" cellpadding=\"5\" rules=\"all\">");
                //写出列名
                data.Append("<tr style=\"font-weight: bold; white-space: nowrap;\">");


                foreach (string s in nameList.Keys)
                {
                    data.Append("<td>" + nameList[s] + "</td>");
                }
                data.Append("</tr>");

                List<V_Zor_Hous> list = Zor_Housing_Bll<V_Zor_Hous>.GetList((V_Zor_Hous)TempData["QueryConditions"], where);
                //写出数据
                foreach (V_Zor_Hous model in list)
                {
                    data.Append("<tr>");
                    foreach (string sm in nameList.Keys)
                    {
                        switch (sm)
                        {                            
                            case "Bd_Name": data.Append("<td>" + model.Bd_Name + "</td>"); ; break;
                            case "Uim_Name": data.Append("<td style='vnd.ms-excel.numberformat:@'>" + model.Uim_Name + "</td>"); ; break;
                            case "Hs_Number": data.Append("<td>" + model.Hs_Number.ToString() + "</td>"); ; break;
                            case "Hs_InFloor": data.Append("<td style='vnd.ms-excel.numberformat:@'>" + model.Hs_InFloor.ToString() + "</td>"); ; break;
                            case "NatPer_Name": data.Append("<td>" + model.NatPer_Name + "</td>"); ; break;
                            case "NatPer_IDNumber": data.Append("<td style='vnd.ms-excel.numberformat:@'>" + model.NatPer_IDNumber + "</td>"); ; break;
                            case "NatPer_Phone": data.Append("<td>" + model.NatPer_Phone + "</td>"); ; break;
                            case "NatSex": data.Append("<td>" + model.NatSex + "</td>"); ; break;
                            case "Hs_Proportion": data.Append("<td style='vnd.ms-excel.numberformat:@'>" + model.Hs_Proportion.ToString() + "</td>"); ; break;
                            case "Nature": data.Append("<td>" + model.Nature + "</td>"); ; break;
                            case "Attribute": data.Append("<td>" + model.Attribute + "</td>"); ; break;
                            case "HousUse": data.Append("<td>" + model.HousUse + "</td>"); ; break;
                            case "Hs_household": data.Append("<td>" + model.Hs_household.ToString() + "</td>"); ; break;
                            case "Cqsx": data.Append("<td>" + model.Cqsx + "</td>"); ; break;
                           
                        }
                    }
                    data.Append("</tr>");
                }
                data.Append("</table>");
            }
            #endregion

            string sw = ExcelHelper.ExcelTemplate(data.ToString());

            string fileName = DateTime.Now.ToString("yyyyMMddHHmmss");
            // 写入到数据流
            return File(System.Text.Encoding.UTF8.GetBytes(sw.ToString()), "application/octet-stream", "房屋信息清单_" + fileName + ".xls");

        }


        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        public ActionResult Zor_Housing(V_Zor_Hous Model, int? index = 1, string where = null)
        {
            int totalCount = 0;
            int pageIndex = index ?? 1;

            PagedList<V_Zor_Hous> zvPager = Zor_Housing_Bll<V_Zor_Hous>.GetPageList(Model,pageIndex, out totalCount, where).AsQueryable().ToPagedList(0, 10) as PagedList<V_Zor_Hous>;

            zvPager.TotalItemCount = totalCount;
            zvPager.CurrentPageIndex = (int)(index ?? 1);

            V_Zor_Hous vh = new V_Zor_Hous();
            vh.PageData = zvPager;
            TempData["QueryConditions"] = Model;//给导出数据传查询条件
            return View(vh);
        }

        /// <summary>
        /// 新增/修改房屋
        /// </summary>
        /// <param name="housing">房屋对象</param>
        /// <returns>执行结果消息</returns>
        [HttpPost]
        public ActionResult AddHousing(V_Zor_Hous housing, Zor_NaturalPerson naturalPerson)
        {
            BaseAnswer bar = new BaseAnswer();
            if (housing.Hs_Id > 0)
                bar = Zor_Housing_Bll<dynamic>.UpdateHousing(housing, naturalPerson);   //修改
            else
                bar = Zor_Housing_Bll<dynamic>.InsertHousing(housing, 2, naturalPerson);   //新增

            return Content(bar.ToJson());

        }



        /// <summary>
        /// 删除房屋信息
        /// </summary>
        /// <param name="id">选中房屋的id</param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult DeleteHousing(int[] id)
        {
            BaseAnswer bar = Zor_Housing_Bll<dynamic>.DeleteHousing(id);
            return Content(bar.ToJson());
        }
        /// <summary>
        /// 查询所有楼宇
        /// create Light by 2017.4.5 
        /// </summary>
        /// <returns></returns>
        public ActionResult SelectBuildingName()
        {
            List<Zor_Building> listNode = Zor_Housing_Bll<Zor_Building>.SelectBuildingName();
            return Content(listNode.ToJson());
        }
        /// <summary>
        /// 查询所在单元
        ///  create liuyunfei by 17-3-27
        /// </summary>
        /// <returns></returns>
        public ActionResult GetBdGround(int id)
        {
            List<Zor_Building> listNode = Zor_Housing_Bll<Zor_Building>.GetBdGround(id);

            return Content(listNode.ToJson());
        }

        /// <summary>
        /// 租赁信息-新增
        /// </summary>
        /// <param name="lease">租赁信息</param>
        /// <param name="startTime">租赁开始时间</param>
        /// <param name="endTime">租赁结束时间</param>
        /// <returns></returns>
        public ActionResult AddHsLease(Zor_Lease lease, DateTime startTime, DateTime endTime)
        {
            BaseAnswer bar = new BaseAnswer();
            lease.Lease_Rent = lease.Lease_Rent * 100;
            bar = Zor_Housing_Bll<dynamic>.InsertHsLease(lease, startTime, endTime);   //新增


            return Content(bar.ToJson());
        }

        #endregion

        #region - 租赁信息管理 -

        /// <summary>
        /// 导出租赁信息列表
        /// create 刘云飞 by 2017/04/06
        /// </summary>
        /// <param name="LeaseMeg">要导出的列表字段集合</param>
        /// <returns>返回数据流</returns>
        [HttpPost]
        public FileResult ExportLease(FormCollection form)
        {
            //this.hdnExcelarr.Value.Split(',');
            string LeaseMeg = form["LeaseMeg"];
            string where = form["where"];
            string[] str_arr = LeaseMeg.Split(',');
            NoSortHashTable nameList = new NoSortHashTable();

            for (int i = 0; i < str_arr.Length; i++)
            {
                if (str_arr[i] != "")
                {
                    string[] item = str_arr[i].Split('|');
                    nameList.Add(item[0], item[1]);
                }
            }

            #region 拼接table

            System.Text.StringBuilder data = new System.Text.StringBuilder();
            if (nameList != null)
            {
                data.Append("<table cellspacing=\"0\" cellpadding=\"5\" rules=\"all\">");
                //写出列名
                data.Append("<tr style=\"font-weight: bold; white-space: nowrap;\">");


                foreach (string s in nameList.Keys)
                {
                    data.Append("<td>" + nameList[s] + "</td>");
                }
                data.Append("</tr>");

                List<V_Lease> list = Zor_Lease_Bll<V_Lease>.GetList((V_Lease)TempData["QueryConditions"], where);
                //写出数据
                foreach (V_Lease model in list)
                {
                    data.Append("<tr>");
                    foreach (string sm in nameList.Keys)
                    {
                        switch (sm)
                        {                            
                            case "Bd_Name": data.Append("<td>" + model.Bd_Name + "</td>"); ; break;
                            case "Hs_Number": data.Append("<td>" + model.Hs_Number + "</td>"); ; break;
                            case "NatPer_Name": data.Append("<td>" + model.NatPer_Name + "</td>"); ; break;
                            case "NatPer_Phone": data.Append("<td>" + model.NatPer_Phone + "</td>"); ; break;
                            case "Hs_Proportion": data.Append("<td>" + model.Hs_Proportion.ToString() + "</td>"); ; break;
                            case "Tenant_Name": data.Append("<td>" + model.Tenant_Name + "</td>"); ; break;
                            case "Lease_Rent": data.Append("<td>" + model.Lease_Rent.ToString() + "</td>"); ; break;
                            case "Lease_StartTime": data.Append("<td>" + TimeHelper.TimeStampToDateTime(model.Lease_StartTime.ToString(), TimeHelper.ToTimeType.link_ymdt) + "</td>"); ; break;
                            case "Lease_EndTime": data.Append("<td>" + TimeHelper.TimeStampToDateTime(model.Lease_EndTime.ToString(), TimeHelper.ToTimeType.link_ymdt) + "</td>"); ; break;
                            case "statue": data.Append("<td>" + model.statue + "</td>"); ; break;
                            case "Lease_Remarks": data.Append("<td>" + model.Lease_Remarks + "</td>"); ; break;
                           
                        }
                    }
                    data.Append("</tr>");
                }
                data.Append("</table>");
            }
            #endregion

            string sw = ExcelHelper.ExcelTemplate(data.ToString());

            string fileName = DateTime.Now.ToString("yyyyMMddHHmmss");
            // 写入到数据流
            return File(System.Text.Encoding.UTF8.GetBytes(sw.ToString()), "application/octet-stream", "租赁信息清单_" + fileName + ".xls");           
        }


        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        public ActionResult Zor_Lease(V_Lease Model,int? index = 1, string where = null)
        {
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_Lease> zvPager = Zor_Lease_Bll<V_Lease>.GetPageList(Model,pageIndex, out totalCount, where).AsQueryable().ToPagedList(0, 10) as PagedList<V_Lease>;
            zvPager.TotalItemCount = totalCount;
            zvPager.CurrentPageIndex = (int)(index ?? 1);

            V_Lease vl = new V_Lease();
            vl.PageData = zvPager;
            TempData["QueryConditions"] = Model;//给导出数据传查询条件
            return View(vl);
        }

        /// <summary>
        /// 新增/修改租赁信息
        /// </summary>
        /// <param name="lease">租赁信息对象</param>
        /// <returns>执行结果消息</returns>
        [HttpPost]
        public ActionResult AddLease(Zor_Lease lease, DateTime startTime, DateTime endTime)
        {
            lease.Lease_Rent = lease.Lease_Rent * 100; //租金转换为分
            BaseAnswer bar = new BaseAnswer();            
            if (lease.Lease_Id > 0)
            {             
                bar = Zor_Lease_Bll<dynamic>.UpdateLease(lease, startTime, endTime);   //修改
            }
            else
            { 
                bar = Zor_Lease_Bll<dynamic>.InsertLease(lease, startTime, endTime);   //新增
            }
            return Content(bar.ToJson());

        }


        /// <summary>
        /// 删除租赁信息
        /// </summary>
        /// <param name="id">选中租赁信息的id</param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult DeleteLease(int[] id)
        {
            BaseAnswer bar = Zor_Lease_Bll<dynamic>.DeleteLease(id);
            return Content(bar.ToJson());
        }

        /// <summary>
        /// 查询房号
        ///  create liuyunfei by 17-3-27
        /// </summary>
        /// <returns></returns>
        public ActionResult GetHsNumber()
        {
            List<Zor_Hous> listNode = Zor_Lease_Bll<Zor_Hous>.GetHsNumber();

            return Content(listNode.ToJson());
        }

        /// <summary>
        /// 查询租户
        ///  create liuyunfei by 17-3-27
        /// </summary>
        /// <returns></returns>
        public ActionResult GetTenant()
        {
            List<Zor_Tenant> listNode = Zor_Lease_Bll<Zor_Tenant>.GetTenant();

            return Content(listNode.ToJson());
        }
      
        /// <summary>
        /// 获取楼宇信息
       /// </summary>
       /// <returns></returns>      
        public ActionResult GetBuildname(int Hs_Falg)
        {
            //获取当前社区对应的楼名名称
            List<Zor_Building> lst_BuildInfo = Zor_Lease_Bll<Zor_Building>.GetBuildname(Hs_Falg);
            return Content(lst_BuildInfo.ToJson());
        }

        /// <summary>
        /// 获取租赁单元信息
        /// </summary>
        /// <returns></returns>
        public ActionResult GetLeaseUimName(int Bd_Id)
        {
            //获取当前社区对应的单元、门牌名称
            List<Zor_UnitInfor> lst_UimInfo = Zor_Lease_Bll<Zor_UnitInfor>.GetUimName(Bd_Id);
            return Content(lst_UimInfo.ToJson());
        }


        /// <summary>
        /// 获取租赁房屋、商铺信息GetHousUse
        /// </summary>
        /// <returns></returns>
        public ActionResult GetHousName(int Uim_Id)
        {
            //获取当前社区对应的房屋、商铺信息
            List<Zor_Hous> lst_HousName = Zor_Lease_Bll<Zor_Hous>.GetHousName(Uim_Id);
            return Content(lst_HousName.ToJson());
        }

        /// <summary>
        /// 获取房屋用途
        /// </summary>
        /// <returns></returns>
        public ActionResult GetHousUse(int Hs_Id)
        {
            //获取当前社区对应的房屋、商铺信息
            List<Zor_Hous> lst_Housuse = Zor_Lease_Bll<Zor_Hous>.GetHousUse(Hs_Id);
            return Content(lst_Housuse.ToJson());
        }   
        #endregion

        #region - 受理单信息管理 -

        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        public ActionResult Zor_Acceptance(V_Acceptance Model,int? index = 1, string where = null)
        {
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_Acceptance> zvPager = Zor_Acceptance_Bll<V_Acceptance>.GetPageList(Model, pageIndex, out totalCount, where).AsQueryable().ToPagedList(0, 10) as PagedList<V_Acceptance>;
            zvPager.TotalItemCount = totalCount;
            zvPager.CurrentPageIndex = (int)(index ?? 1);
            V_Acceptance va = new V_Acceptance();
            va.PageData = zvPager;
            return View(va);
        }


        /// <summary>
        /// 新增受理单信息
        /// </summary>
        /// <param name="acceptance">受理单信息对象</param>
        /// <returns>执行结果消息</returns>

        public ActionResult InsertAcceptance(string LeaseId, int PropertyTax, int PersonalTax, int Acceptance_Tax, int Acceptance_TotalTax, string Acceptance_TaxNumber, string Acceptance_Address, DateTime startTime, DateTime endTime)
        {
            BaseAnswer bar = Zor_Acceptance_Bll<dynamic>.InsertAcceptance( LeaseId, PropertyTax, PersonalTax, Acceptance_Tax, Acceptance_TotalTax, Acceptance_TaxNumber, Acceptance_Address, startTime, endTime);   //新增

            return Content(bar.ToJson());

        }

        /// <summary>
        /// 修改受理单信息
        /// </summary>
        /// <param name="acceptance">受理单信息对象</param>
        /// <returns>执行结果消息</returns>
        [HttpPost]
        public ActionResult AddAcceptance(int PropertyTax,int PersonalTax,int Acceptance_Tax,int Acceptance_TotalTax,Zor_Acceptance acceptance, DateTime startTime, DateTime endTime)
        {

            BaseAnswer bar = Zor_Acceptance_Bll<dynamic>.UpdateAcceptance(PropertyTax,PersonalTax,Acceptance_Tax,Acceptance_TotalTax,acceptance, startTime, endTime);   //修改
            

            return Content(bar.ToJson());

        }

        /// <summary>
        /// 删除受理单信息
        /// </summary>
        /// <param name="id">选中受理单信息的id</param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult DeleteAcceptance(int[] id)
        {
            BaseAnswer bar = Zor_Acceptance_Bll<dynamic>.DeleteAcceptance(id);
            return Content(bar.ToJson());
        }

        /// <summary>
        /// 推送
        /// create zhl by 17.3.30
        /// </summary>
        /// <param name="id">受理单id</param>
        /// <param name="acceptancestate">受理单状态</param>
        /// <returns>2--当前受理单已推送-1操作失败1--操作成功的标识</returns> 
        public ActionResult AccPush(int acceptanceid, int acceptancestate)
        {
            string messge = Zor_NaturalPerson_Bll<dynamic>.AccPush(acceptanceid, acceptancestate);
            string msg = "{'AnswerMeg':'" + messge + "'}";
            return Content(msg.ToJson().ToString());
      
        }

        #endregion

        #region - 受理单打印-社区 -

        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        public ActionResult Zor_Acceptance_Sq(int? index = 1, string where = null)
        {
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_Zor_Acceptance_Sq> zvPager = Zor_Acceptance_Bll<V_Zor_Acceptance_Sq>.GetPageListSq(pageIndex, out totalCount, where).AsQueryable().ToPagedList(0, 10) as PagedList<V_Zor_Acceptance_Sq>;
            zvPager.TotalItemCount = totalCount;
            zvPager.CurrentPageIndex = (int)(index ?? 1);

            V_Zor_Acceptance_Sq va = new V_Zor_Acceptance_Sq();
            va.PageData = zvPager;
            return View(va);
        }

        /// <summary>
        ///加载用户打印区域 
        /// </summary>
        /// <param name="dayReport_id"></param>
        /// <returns></returns>
    
        public ActionResult LoadAcceptancePrint(int  Acceptance_Id)
        {
            List<V_Zor_Acceptance_Sq> listDtName = Zor_Acceptance_Bll<V_Zor_Acceptance_Sq>.GetAcceptancePrint(Acceptance_Id);
            return Content(listDtName.ToJson());
        }

        #endregion

        #region - 受理单打印-街道办 -

        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        public ActionResult Zor_Acceptance_Jdb(int? index = 1, string where = null)
        {
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_Zor_Acceptance_Jdb> zvPager = Zor_Acceptance_Bll<V_Zor_Acceptance_Jdb>.GetPageListJdb(pageIndex, out totalCount, where).AsQueryable().ToPagedList(0, 10) as PagedList<V_Zor_Acceptance_Jdb>;
            zvPager.TotalItemCount = totalCount;
            zvPager.CurrentPageIndex = (int)(index ?? 1);

            V_Zor_Acceptance_Jdb va = new V_Zor_Acceptance_Jdb();
            va.PageData = zvPager;
            return View(va);
        }

        #endregion

        #region - 完税证管理 -


        /// <summary>
        /// 加载数据
        /// create by liuqi at  2017.4.5
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        public ActionResult Zor_Certificate(int? index = 1, string startDate = "", string endDate = "", string collarMan = "0", string State = "4")
        {
            #region 查询条件
            string where = "";
            int dt_id = RequestSession.GetSessionUser().DT_Id;
            where = "(Certificate_CreateTime>=" + TimeHelper.ToTimeStamp(DateTime.Parse(startDate == "" ? "1970-01-01 00:00:00" : startDate + " 00:00:00"))
                  + " and Certificate_CreateTime<=" + TimeHelper.ToTimeStamp(DateTime.Parse(endDate == "" ? endDate = DateTime.Now.ToShortDateString() + " 23:59:59" : endDate + " 23:59:59")) + ")"
                  + (collarMan == "0" ? " and 1=1" : " and Certificate_CollarMan=" + collarMan)
                  + (State == "4" ? " and 1=1" : " and Certificate_State=" + State)
                  + (dt_id == 0 ? " and 1=1" : " and Dt_ParentId=" + dt_id);
            #endregion
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_Zor_Certificate> zvPager = Zor_Certificate_Bll<V_Zor_Certificate>.GetPageList(pageIndex, out totalCount, where).AsQueryable().ToPagedList(0, 10) as PagedList<V_Zor_Certificate>;
            zvPager.TotalItemCount = totalCount;
            zvPager.CurrentPageIndex = (int)(index ?? 1);
            //实例化视图对象
            V_Zor_Certificate va = new V_Zor_Certificate();
            va.PageData = zvPager;
            return View(va);
        }

        /// <summary>
        /// 新增/修改完税证信息
        /// create by liuqi at  2017.4.5
        /// </summary>
        /// <param name="lease">完税证信息对象</param>
        /// <returns>执行结果消息</returns>
        [HttpPost]
        public ActionResult AddZor_Certificate(Zor_Certificate certificate, string oldZigui, bool isAddAlter)
        {
            BaseAnswer bar = new BaseAnswer();
            if (!isAddAlter && certificate.Certificate_Id > 0)
                bar = Zor_Certificate_Bll<dynamic>.AlterCertificate(certificate);   //修改
            else
                bar = Zor_Certificate_Bll<dynamic>.InsertCertificate(certificate);   //新增
            return Content(bar.ToJson());
        }

        /// <summary>
        /// 删除完税证信息
        /// create by liuqi at  2017.4.5
        /// </summary>
        /// <param name="id">选中完税证信息的id</param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult Delete_Certificate(int[] id)
        {
            BaseAnswer bar = Zor_Certificate_Bll<dynamic>.DeleteCertificate(id);
            return Content(bar.ToJson());
        }

        /// <summary>
        /// 查询所有街道办
        /// create by liuqi at  2017.4.5
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult GetStreetOffice()
        {
            List<Sys_Department> lstStreetOffice = Zor_Certificate_Bll<Sys_Department>.GetStreetOffice();
            return Content(lstStreetOffice.ToJson());
        }

        /// <summary>

       

        /// 停用完税证
        /// create by liuqi at  2017.4.5
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult Stop_Certificate(int[] id)
        {
            BaseAnswer bar = new BaseAnswer();
            bar = Zor_Certificate_Bll<dynamic>.StopCertificate(id);   //修改
            return Content(bar.ToJson());
        }
        #endregion

        #region - 金三录入管理器 -

        /// 新增金三录入信息
        /// </summary>
        /// <param name="jinsan">金三录入对象</param>
        /// <returns>执行结果消息</returns>
        [HttpPost]
        public ActionResult AddJinSan(V_Zor_InputJinSan jinsan)
        {
            BaseAnswer bar = new BaseAnswer();
            bar = Zor_InputJinSan_Bll<dynamic>.InsertJinSan(jinsan);   //新增

            return Content(bar.ToJson());

        }

        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        public ActionResult Zor_InputJinSan(V_Zor_InputJinSan Model, int? index = 1, string where = null)
        {
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_Zor_InputJinSan> rsPager = Zor_InputJinSan_Bll<V_Zor_InputJinSan>.GetPageList(Model,pageIndex, out totalCount, where).AsQueryable().ToPagedList(0, 10) as PagedList<V_Zor_InputJinSan>;
            rsPager.TotalItemCount = totalCount;
            rsPager.CurrentPageIndex = (int)(index ?? 1);

            V_Zor_InputJinSan vr = new V_Zor_InputJinSan();
            vr.PageData = rsPager;
            return View(vr);
        }
        
        #endregion

        #region - 金三销号管理器 -


        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>

        public ActionResult Zor_RepealJinSan(V_Zor_RepealJinSan Model, int? index = 1, string where = null)
        {
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_Zor_RepealJinSan> rsPager = Zor_RepealJinSan_Bll<V_Zor_RepealJinSan>.GetPageList(Model, pageIndex, out totalCount, where).AsQueryable().ToPagedList(0, 10) as PagedList<V_Zor_RepealJinSan>;
            rsPager.TotalItemCount = totalCount;
            rsPager.CurrentPageIndex = (int)(index ?? 1);

            V_Zor_RepealJinSan vr = new V_Zor_RepealJinSan();
            vr.PageData = rsPager;
            return View(vr);
        }
        /// <summary>
        ///金三销号
        /// </summary>
        /// <param name="Js_Id">选中金三销号的id</param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult RepealJinSan(int Jsid, int AcceptanceId)
        {
            BaseAnswer bar = Zor_RepealJinSan_Bll<dynamic>.RepealJinSan(Jsid, AcceptanceId);
            return Content(bar.ToJson());
        }    
        #endregion

        #region - 完税证作废 -


        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>

        public ActionResult Zor_CertificateRecord(V_Zor_CertificateRecord Model, int? index = 1, string where = null)
        {
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_Zor_CertificateRecord> rsPager = Zor_CertificateRecord_Bll<V_Zor_CertificateRecord>.GetPageList(Model,pageIndex, out totalCount,where).AsQueryable().ToPagedList(0, 10) as PagedList<V_Zor_CertificateRecord>;
            rsPager.TotalItemCount = totalCount;
            rsPager.CurrentPageIndex = (int)(index ?? 1);

            V_Zor_CertificateRecord vr = new V_Zor_CertificateRecord();
            vr.PageData = rsPager;
            return View(vr);
        }
        /// <summary>
        ///完税证作废
        /// </summary>
        /// <param name="id">选中完税证作废id</param>
        /// /// <param name="AcceptanceId">选中受理单id</param>
        /// /// <param name="PtId">选中缴税管理id</param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult CertificateCancel(int id, int AcceptanceId, int PtId, int CRID)
        {
            BaseAnswer bar = Zor_CertificateRecord_Bll<dynamic>.CertificateCancel(id, AcceptanceId, PtId, CRID);
            return Content(bar.ToJson());
        }
        #endregion

        #region - 完税证启用 -


        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="where">条件</param>
        /// <returns></returns>

        public ActionResult Zor_CertificateStart(V_Zor_CertificateStart Model, int? index = 1, string where = null)
        {
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_Zor_CertificateStart> rsPager = Zor_CertificateStart_Bll<V_Zor_CertificateStart>.GetPageList(Model, pageIndex, out totalCount, where).AsQueryable().ToPagedList(0, 10) as PagedList<V_Zor_CertificateStart>;
            rsPager.TotalItemCount = totalCount;
            rsPager.CurrentPageIndex = (int)(index ?? 1);

            V_Zor_CertificateStart vr = new V_Zor_CertificateStart();
            vr.PageData = rsPager;
            return View(vr);
        }
        /// <summary>
        ///完税证启用
        /// </summary>
        /// <param name="id">选中完税证启用id</param>
        /// /// <param name="AcceptanceId">选中开始完税证号/param>
        /// /// <param name="PtId">选中缴税管理id</param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult CertificateStarted(int id, int StartTaxNum, int EndTaxNum)
        {
            BaseAnswer bar = Zor_CertificateStart_Bll<dynamic>.CertificateStart(id, StartTaxNum, EndTaxNum);
            return Content(bar.ToJson());
        }
        #endregion

        #region - 地图页面 -

        public ActionResult SearchMap()
        {
            return View();
        }

        public ActionResult SearchMapShop()
        {
            return View();
        }

        /// <summary>
        /// 获取楼宇下拉菜单
        /// </summary>
        /// <returns></returns>
        public ActionResult ListAddress()
        {
            string stdata;
            List<dynamic> lstBuilding = CommunityPreview_Bll<dynamic>.GetListAddress();
            if (lstBuilding.Count == 0)
            {
                stdata = "西安市莲湖区";
            }
            else
            {
                stdata = "西安市莲湖区" + lstBuilding[0].Dt_Name;
            } 
           
            return Content(stdata);
        }
        #endregion

        #region - 发票号重录 -
        public ActionResult InvoiceRemake(V_InvoiceRemake model, int? index = 1, string where = null)
        {
            int totalCount = 0;
            int pageIndex = index ?? 1;
            PagedList<V_InvoiceRemake> zvPager = InvoiceRemake_Bll<V_InvoiceRemake>.GetPageList(model, pageIndex, out totalCount, where).AsQueryable().ToPagedList(0, 10) as PagedList<V_InvoiceRemake>;
            zvPager.TotalItemCount = totalCount;
            zvPager.CurrentPageIndex = (int)(index ?? 1);
            V_InvoiceRemake vb = new V_InvoiceRemake();
            vb.PageData = zvPager;
            return View(vb);
        }
         ///<summary>
        /// 发票号重录列表
        /// </summary>
        /// <returns></returns>
        public ActionResult Invoice_Remake(string where)
        {
            List<V_InvoiceRemake> list = InvoiceRemake_Bll<V_InvoiceRemake>.Invoice_Remake(where);
            return Content(list.ToJson());
        }
        /// <summary>
        /// 重录发票号
        /// </summary>
        /// <returns></returns>      
        public ActionResult Update_Invoice(int In_Id)
        {
            List<V_InvoiceRemake> list_up = InvoiceRemake_Bll<V_InvoiceRemake>.UpdateInvoice(In_Id);
            return Content(list_up.ToJson());
        }

        /// <summary>
        /// 更改发票号
        /// </summary>
        /// <returns></returns>      
        public ActionResult Invoice_New(int In_Id, string InNumBer)
        {
            List<V_InvoiceRemake> list_new = InvoiceRemake_Bll<V_InvoiceRemake>.Invoice_New(In_Id, InNumBer);
            return Content(list_new.ToJson());
        }
        /// <summary>
        /// 第二次更改发票号
        /// </summary>
        /// <returns></returns>      
        public ActionResult Invoice_Two(int In_Id, string InNumBer)
        {
            List<V_InvoiceRemake> list_new = InvoiceRemake_Bll<V_InvoiceRemake>.Invoice_Two(In_Id, InNumBer);
            return Content(list_new.ToJson());
        }
        /// <summary>
        /// 第三次更改发票号
        /// </summary>
        /// <returns></returns>      
        public ActionResult Invoice_Three(int In_Id, string InNumBer)
        {
            List<V_InvoiceRemake> list_new = InvoiceRemake_Bll<V_InvoiceRemake>.Invoice_Three(In_Id, InNumBer);
            return Content(list_new.ToJson());
        }
        /// <summary>
        /// 获取发票号
        /// </summary>
        /// <returns></returns>      
        public ActionResult Invoice_Get(int In_Id)
        {
            List<V_InvoiceRemake> list_new = InvoiceRemake_Bll<V_InvoiceRemake>.Invoice_Get(In_Id);
            return Content(list_new.ToJson());
        }
        #endregion
    }
}


